﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

namespace XFramework.Editor
{
    public class Animation
    {
        [MenuItem("XFramework/Anim/ChangeName")]
        public static void ChangeAnimName()
        {
            foreach (var item in Selection.objects)
            {
                string path = AssetDatabase.GetAssetPath(item);
                AssetImporter importer = AssetImporter.GetAtPath(path);
                if (importer != null && importer is ModelImporter modelImporter)
                {
                    modelImporter.clipAnimations[0].name = item.name;
                    modelImporter.clipAnimations[0].takeName = item.name;
                    AssetDatabase.Refresh();
                }
            }
        }
    }
}